package offer.singleLinkedList;


import java.util.Stack;

/**
 * Description：
 * Author: zhangc
 * Date：2017/7/18 15:12
 */
public class PrintList5 {

    public static <T> void  printList(LinkedList<T> list){
        if (list != null){
            if(list.getNext() != null)
                printList(list.getNext());
            System.out.println(list.getValue());
        }
    }

    public static <T> void  printListNoRecursive(LinkedList<T> list){
        Stack<T> stack = new Stack<>();
        while (list != null) {
            stack.push(list.getValue());
            list = list.getNext();
        }
        while (!stack.isEmpty()){
            System.out.println(stack.pop());
        }
    }

}
